﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.LIB;

namespace HangerSupport
{
	public partial class DlgHSSelect : System.Windows.Forms.Form
	{
		private void DlgHSSelect_FormClosed(object sender, FormClosedEventArgs e)
		{
			DlgHSSelect.g_Dlg_X = base.Location.X;
			DlgHSSelect.g_Dlg_Y = base.Location.Y;
		}

		public DlgHSSelect(HSTypeInfo HSTypeManage, HSDefineInfo selHSDefineInfo)
		{
			this.InitializeComponent();
			YJKProcessTools hyprocessTools = new YJKProcessTools();
			hyprocessTools.ShowInTaskbarChange(this);
			base.Location = new System.Drawing.Point(DlgHSSelect.g_Dlg_X, DlgHSSelect.g_Dlg_Y);
			this.m_HSTypeManage = HSTypeManage;
			this.m_selHSDefineInfo = selHSDefineInfo;
			this.listViewHS.View = View.LargeIcon;
			bool flag = this.m_HSTypeManage.IsSupport(this.m_selHSDefineInfo);
			this.ViewList(flag);
			bool flag2 = flag;
			if (flag2)
			{
				this.rdoSupport.Select();
			}
			else
			{
				this.rdoHanger.Select();
			}
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			bool flag = this.listViewHS.SelectedItems.Count == 0;
			if (!flag)
			{
				HSDefineInfo selHSDefineInfo = (HSDefineInfo)this.listViewHS.SelectedItems[0].Tag;
				this.m_selHSDefineInfo = selHSDefineInfo;
			}
		}

		public HSDefineInfo GetSelect()
		{
			return this.m_selHSDefineInfo;
		}

		private void AddBmpItem(HSDefineInfo curDef)
		{
			ListViewItem listViewItem = new ListViewItem();
			listViewItem.Name = curDef.m_strName;
			listViewItem.Text = curDef.m_strName;
			listViewItem.ToolTipText = curDef.m_strTip;
			listViewItem.ImageKey = curDef.m_strBmp;
			listViewItem.Tag = curDef;
			this.listViewHS.Items.Add(listViewItem);
		}

		private void ViewList(bool bIsSupport = true)
		{
			this.listViewHS.Clear();
			this.listViewHS.SelectedItems.Clear();
			string key = "多层吊架";
			if (bIsSupport)
			{
				key = "多层支架";
				this.listViewHS.LargeImageList = this.imageListSupport;
			}
			else
			{
				key = "多层吊架";
				this.listViewHS.LargeImageList = this.imageListHunger;
			}
			foreach (HSDefineInfo hsdefineInfo in this.m_HSTypeManage.m_lstHSType)
			{
				bool flag = (!bIsSupport && hsdefineInfo.m_eType >= HSType.kDJ_DC) || (bIsSupport && hsdefineInfo.m_eType < HSType.kDJ_DC);
				if (flag)
				{
					this.AddBmpItem(hsdefineInfo);
					bool flag2 = this.m_selHSDefineInfo.m_eType == hsdefineInfo.m_eType;
					if (flag2)
					{
						key = hsdefineInfo.m_strName;
					}
				}
			}
			this.listViewHS.Items[key].Selected = true;
		}

		private void rdoSupport_CheckedChanged(object sender, EventArgs e)
		{
			this.ViewList(true);
		}

		private void rdoHanger_CheckedChanged(object sender, EventArgs e)
		{
			this.ViewList(false);
		}

		private void listViewHS_MouseDoubleClick(object sender, MouseEventArgs e)
		{
			bool flag = e.Button == MouseButtons.Left;
			if (flag)
			{
				this.btnOk_Click(sender, e);
				base.DialogResult = DialogResult.OK;
				base.Close();
			}
		}

		private HSTypeInfo m_HSTypeManage;

		private HSDefineInfo m_selHSDefineInfo;

		private static int g_Dlg_X = 10;

		private static int g_Dlg_Y = 10;
	}
}
